from ronglian_sms_sdk import SmsSDK
import json
import random

accId = "8aaf070875e449d70175f3265f4205c9"
accToken = "a8df03e864fc47aa8cfac8935751766e"
appId = "8aaf070875e449d70175f326605105cf"



def send_message(phone):
    sdk = SmsSDK(accId,accToken,appId)
    tid = "1"
    mobile = phone
    random_str = ''
    for i in range(6):
        random_str += str(random.randint(0,10))
    datas = (random_str,"5")
    resp = sdk.sendMessage(tid,mobile,datas)
    print(resp)
    resp_body = json.load(resp)
    if resp_body.get('statuCode')=='000000':
        print(resp_body.get('templateSMS'))
        templateSMS = resp_body.get("templateSMS")
        smsMessageSid = templateSMS.get("smsMessageSid")
        return smsMessageSid,random_str
    else:
        return None

if __name__ == "__main__":
    print(send_message("18611777352"))